﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Collections;

namespace CDTM.Modules.TraCuuDiem.Components
{
    public partial class TotNghiepTC
    {
        public static List<TotNghiepTC> Clean(List<TotNghiepTC> list)
        {
            List<TotNghiepTC> newList = new List<TotNghiepTC>();

            var removeList = from item in list where item.MaSV != "" select item;

            foreach (TotNghiepTC obj in removeList)
            {
                newList.Add(obj);
            }

            return newList;
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteAll()
        {
            return DeleteDynamic("1=1");
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteDynamic(string whereCondition)
        {
            const string spName = "[dbo].[p_CDTM_TCD_TotNghiepTC_DeleteDynamic]";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@WhereCondition", SqlDbType.Text, whereCondition);

            return db.ExecuteNonQuery(dbCommand);
        }

    }
}
